package com.bus.boot.manager.assist.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bus.boot.dao.assist.BusGuestbookCtgDao;
import com.bus.boot.entity.assist.BusGuestbookCtg;
import com.bus.boot.manager.assist.BusGuestbookCtgMng;
import com.bus.common.hibernate4.Updater;

@Service
@Transactional
public class BusGuestbookCtgMngImpl implements BusGuestbookCtgMng {
	@Transactional(readOnly = true)
	public List<BusGuestbookCtg> getList(Integer siteId) {
		return dao.getList(siteId);
	}

	@Transactional(readOnly = true)
	public BusGuestbookCtg findById(Integer id) {
		BusGuestbookCtg entity = dao.findById(id);
		return entity;
	}

	public BusGuestbookCtg save(BusGuestbookCtg bean) {
		dao.save(bean);
		return bean;
	}

	public BusGuestbookCtg update(BusGuestbookCtg bean) {
		Updater<BusGuestbookCtg> updater = new Updater<BusGuestbookCtg>(bean);
		bean = dao.updateByUpdater(updater);
		return bean;
	}

	public BusGuestbookCtg deleteById(Integer id) {
		BusGuestbookCtg bean = dao.deleteById(id);
		return bean;
	}

	public BusGuestbookCtg[] deleteByIds(Integer[] ids) {
		BusGuestbookCtg[] beans = new BusGuestbookCtg[ids.length];
		for (int i = 0, len = ids.length; i < len; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}

	private BusGuestbookCtgDao dao;

	@Autowired
	public void setDao(BusGuestbookCtgDao dao) {
		this.dao = dao;
	}
}